#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i)  
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;

const int N = 100010;
int n,x_1,x_2,y_1,y_2,tot_line,tot_x,tot_point,tot_tree,L,R;
ll point[4*N],ans;

struct LINE{
    int l,r,h,v;
}line[4*N];

struct node{
    int l,r;
    ll sum,len;
    node * ls, * rs;
}Tree[4*N];

inline bool cmp1(LINE a,LINE b){return a.h<b.h;}
inline bool cmp2(int x,int y){return x<y;}

inline node * create(){return &Tree[++tot_tree];}

inline void build(node * cur,int l,int r){
    cur->l = l , cur->r = r , cur->sum = cur->len = 0;
    if(l == r) return;
    int mid = (l+r)>>1;
    cur->ls = create() , cur->rs = create();
    build(cur->ls,l,mid) , build(cur->rs,mid+1,r);
    return;
}

inline void pushup(node * cur){
    if(cur->sum) cur->len = point[cur->r+1] - point[cur->l];
    else cur->len = cur->ls->len + cur->rs->len;
}


inline void edit(node * cur,int k){
    // cout << "now editing " << L << " " << R << " " << point[cur->l] << " " << point[cur->r+1] << " " << k << "\n";
    int l = cur->l , r = cur->r;
    if(L >= point[r+1] || R <= point[l]) return;
    if(L <= point[l] && R >= point[r+1]){
        cur->sum += k;
        if(cur->l != cur->r) pushup(cur);
        else{ if(cur->sum) cur->len = point[cur->r+1] - point[cur->l];else cur->len = 0;}
        return;
    }
    edit(cur->ls,k) , edit(cur->rs,k);
    pushup(cur);
    return;
}

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("in.in", "r", stdin);
    cin >> n;
    rep(i,1,n){
        cin >> x_1 >> y_1 >> x_2 >> y_2;
        line[++tot_line].l = x_1 , line[tot_line].r = x_2 , line[tot_line].h = y_1 , line[tot_line].v = 1;
        line[++tot_line].l = x_1 , line[tot_line].r = x_2 , line[tot_line].h = y_2 , line[tot_line].v = -1;
        point[++tot_point] = x_1 , point[++tot_point] = x_2; 
    }
    std::sort(line+1,line+tot_line+1,cmp1) , std::sort(point+1,point+tot_point+1,cmp2);
    tot_x = std::unique(point+1,point+tot_point+1)-point-1;//离散化
    node * root = create();
    build(root,1,tot_x-1);
    rep(i,1,tot_line){
        L = line[i].l , R = line[i].r;
        edit(root,line[i].v);pushup(root);
        ans += root->len * (line[i+1].h - line[i].h);
    }
    cout << ans << "\n";
    return 0;
}